What is unzip-response?
The unzip-response npm package is used to decompress HTTP responses that have been compressed using gzip, deflate, or Brotli. It is particularly useful when working with HTTP clients that do not automatically handle decompression of response bodies.
Decompress HTTP Response
This feature allows you to decompress an HTTP response that has been compressed using gzip, deflate, or Brotli. The code sample demonstrates how to use the unzip-response package to handle a compressed HTTP response and log the decompressed data to the console.
const http = require('http');
const unzipResponse = require('unzip-response');
http.get('http://example.com', response => {
response = unzipResponse(response);
response.on('data', chunk => {
console.log(chunk.toString());
});
});